package BasicClient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;


public abstract class AbstractClient extends Observable implements Client {
    protected int pID;    
    private Server pokerServ;
    
    protected HashMap<Integer, PokerPlayer> playerMap;
    protected ArrayList<String> tableCards;
    protected ArrayList<String> holeCards;
    protected int dealerButtonLocation;
    protected int bigBlind;
    protected int smallBlind;
    protected int stackSize;
    protected int handID;
    protected int tableID;
    
    
	public AbstractClient(){
		// This will be initialized after a call to connect
		pokerServ = null;
		
		// This will be initialized after a player ID request
		pID = -1;
		
		// This will be initialized after a get seat request
		playerMap = new HashMap<Integer, PokerPlayer>();	
		
		// Variables for the game state
		tableCards = new ArrayList<String>();
		holeCards = new ArrayList<String>();
		dealerButtonLocation = -1;
		bigBlind = -1;
		smallBlind = -1;
		stackSize = -1;
		handID = -1;
		tableID = -1;
	}
	
	public void setServer(Server server){
		this.pokerServ = server;
	}
	
	//--------------------------------------------------------
	// Getters for the game state variables
	//--------------------------------------------------------
	public HashMap<Integer, PokerPlayer> getPlayers(){return playerMap;}	
	public ArrayList<String> getTableCards(){return tableCards;}	
	public ArrayList<String> getHoleCards(){return holeCards;}	
	public int getDealerButtonLocation(){return dealerButtonLocation;}
	public int getBigBlind(){return bigBlind;}
	public int getSmallBlind(){return smallBlind;}
	public int getHandID(){return handID;}
	public int getTableID(){return tableID;}
	
	
	//--------------------------------------------------------
	// This section of methods just forwards the call to the server, which
	// will convert the request into the Forbes protocol and send it
	//--------------------------------------------------------
	public void actionCall(){pokerServ.actionCall(this.pID);}
	public void actionRaise(int amount){pokerServ.actionRaise(pID, amount);}
	public void actionFold(){pokerServ.actionFold(pID);}
	public void actionCheck(){pokerServ.actionCheck(pID);}
	public void requestBlinds(){pokerServ.requestBlinds(pID);}
	public void requestSeat(){pokerServ.requestSeat(pID);}
	public void requestPlayerId(){pokerServ.requestPlayerId();}	
}
